package com.chb.system.controller;

import com.chb.system.service.UserService;
import com.hos.entity.sys.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author: 陈海彬
 * @date: Created in 2023/12/7 19:38
 * @description:
 * @modified By:
 * @version:
 */
@RestController
@RequestMapping("system/user")
public class UserController {

    @Autowired
    private UserService userService;
    

    /**
     * 根据手机号查询所有的用户
     *
     * @param phone
     * @return
     */
    @GetMapping("selectUserByPhone/{phone}")
    public User selectUserByPhone(@PathVariable String phone) {
        return userService.findUserByPhone(phone);
    }


    /**
     * @param params 用户id  部门id
     * @return java.util.List<com.hos.entity.sys.User>
     * @create by: 陈海彬
     * @description: 根据用户id和部门id查询用户列表
     * @create time: 2023/12/11 20:03
     */
    @PostMapping("getUser")
    List<User> getUser(@RequestBody Map<String, Object> params) {
        return userService.getUserByParams(params);
    }

    /**
     * 根据用户ID查找用户
     *
     * @param userid 用户ID
     * @return 根据用户ID查询到的用户
     */
    @GetMapping("getUserById/{userid}")
    public User getUserById(@PathVariable Long userid) {
        return userService.getUserById(userid);
    }

    /**
     * 查询所有可用的用户
     * @return
     */
    @GetMapping("selectAllUser")
    public List<User> selectAllUser() {
        return userService.selectAllUser();
    }
}